package com.tanger;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity;
import org.springframework.security.oauth2.config.annotation.web.configuration.EnableOAuth2Client;

/**
 * 修改启动类，继承 SpringBootServletInitializer 并重写 configure 方法
 * @EnableOAuth2Client
 * 1.允许在Spring Security Web应用程序中配置OAuth2客户端
 * 2.允许使用来自一个或多个OAuth2授权服务器的授权代码授权
 * 3.允许自动连接OAuth2ClientContext，可以用来创建OAuth2RestTemplate Bean
 *@EnableGlobalMethodSecurity(prePostEnabled = true)
 * 开启spring方法级安全,prePostEnabled=true在方法执行后均进行验证
 */

//@EnableAsync //开启异步调用
@EnableOAuth2Client
@EnableGlobalMethodSecurity(prePostEnabled = true)
@SpringBootApplication
public class TangerApplication extends SpringBootServletInitializer {

    public static void main(String[] args) {
        new SpringApplication(TangerApplication.class).run(args);
    }

    @Override
    protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) {
        // 注意这里要指向原先用main方法执行的Application启动类
        return builder.sources(TangerApplication.class);
    }
}